package com.heima.exam.p5;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("127.0.0.1", 20000);
        OutputStream outputStream = s.getOutputStream();
        FileInputStream fis = new FileInputStream("src/com/heima/exam/p5/1.jpg");
        byte[] bytes = new byte[1024];
        int len;
        while ((len = fis.read(bytes)) != -1) {
            outputStream.write(bytes, 0, len);
        }
        s.shutdownOutput();

        InputStream inputStream = s.getInputStream();
        while ((len = inputStream.read(bytes)) != -1) {
            System.out.println(new String(bytes, 0, len));
        }
        inputStream.close();
        outputStream.close();
        s.close();
    }
}
